#!/bin/bash


# The fqdn for your Munki Web Admin server.
# EXAMPLE: https://example.com
MWA_HOST="http://example.com:8000"

# The optional name of your SSL certificate to use when communicating with
# Munki Web Admin. If you place the certificate in the same directory as this
# script, you don't need to include the full path.
# EXAMPLE: "munkiwebadmin.crt"
MWA_SSL_CERTIFICATE=""

# An optional whitelist of IP address prefixes from which Munki Web Admin
# communication is allowed.
# EXAMPLE: ( 192.168 172.2 )
MWA_ALLOWED_NETWORKS=( )






# This function is used by the other three scripts when curl needs to be
# invoked. It transparently uses the SSL certificate when one has been
# specified in $MWA_SSL_CERTIFICATE. It also defaults to using the "--silent"
# flag.
function mwa_curl
{
	# production mode
	paramList=" --silent"

	# debug mode
	# paramList=""

	if [ ! -z "${MWA_SSL_CERTIFICATE}" ]
	then
		# a cert was specified, can we find it?
		if [ -e "${MWA_SSL_CERTIFICATE}" ]
		then
			paramList="${paramList} --cacert ${MWA_SSL_CERTIFICATE}"
		else
			echo "Cannot locate cert named '${MWA_SSL_CERTIFICATE}'"
		fi
	fi
	for _param_ in $@
	do
		paramList="${paramList} ${_param_}"
	done
	/bin/bash -c "/usr/bin/curl$paramList"
}
